\documentclass[11pt, a4paper]{article}
\usepackage{color}
\usepackage{listings}
\usepackage{fullpage}
\usepackage{amsfonts}
\usepackage[latin1]{inputenc}
\usepackage[english]{babel}
\usepackage[T1]{fontenc}
\usepackage{graphicx}
\usepackage{amsmath,amssymb}
\usepackage{graphicx}
\usepackage{fancyhdr}           %Min header begynder
\pagestyle{fancy}
\fancyhf{}
\setlength{\headheight}{14pt}
\setlength{\headsep}{25pt}
\fancyhead[L]{Connect Four}  %Header venstre
\fancyhead[C]{Group I}			 %header center
\fancyhead[R]{ISP 2012, ITU} 		 %header h�jre
\fancyfoot[R]{\thepage} 				 %Sidetal i bunden
\renewcommand\headrulewidth{0.4pt}
\renewcommand\footrulewidth{0.4pt}

\author{Mark Gray, Johan Sivertsen \& Lauge Groes}
\title{Intelligent Systems Programming, Assignment 2: N-Queens}
\date{\today}
\begin{document}

\lstset{language=Java, breaklines = true, identifierstyle=\ttfamily,
keywordstyle=\color[rgb]{0.700,0.100,0.500},
commentstyle=\color[rgb]{0.133,0.545,0.133},
stringstyle=\color[rgb]{0,0,1}, extendedchars=true,
basicstyle=\scriptsize,numbers=left,numberstyle=\tiny}
\maketitle
\newpage

%\begin{figure}
%\lstinputlisting[firstline=1,lastline=109,firstnumber=1]{../src/MiniMaxAB.java}
%\caption{ Excerpt of code}\label{MinimaxAB}
%\end{figure}

This solution uses two BDD structures. One called mainBDD and one called QueensBDD. QueensBDD is a 2d-array of BDD's, each reprensenting one position on the board. Initially MainBDD is constructed by adding rules constricting the BDD to the rules of the N-Queen puzzle; Only one queen on a row, column and diagonal, and at least one queen per row(N queens on an N size board.).

\begin{figure}
\lstinputlisting[firstline=41,lastline=71,firstnumber=41]{QueensLogic.java}
\caption{Constructing mainBDD}\label{mainBDD}
\end{figure}

When adding a Queen MainBDD is restricted with the relevant QueensBDD. Then we run three loops. The first puts crosses on the board in positions that would make the puzzel unsolveable. This is checked by using the BDD API's .isZero method. The second checks the number of open places and queens, and the third places the missing queens if the numbers correspond.

\begin{figure}[t!]
\lstinputlisting[firstline=87,lastline=119,firstnumber=87]{QueensLogic.java}
\caption{Restricting with QueensBDD}\label{QueensBDD}
\end{figure}
\end{document}

